package com.ds.robot.assistant.enums;


import lombok.Getter;

@Getter
public enum MilestoneType {


    REVIEW_COMPLETED(10, "完成评审"),

    WORKLOAD_ASSESSED(20, "完成工作量评估"),
    // TECHNICAL_COMPLETED(25, "完成技术方案"),


    //某个人
    ALL_DEVELOPMENT_COMPLETED_AND_DEBUG(30, "完成开发"),

    FRONTEND_DEVELOPMENT_COMPLETED(31, "完成前端开发"),
    BACKEND_DEVELOPMENT_COMPLETED(32, "完成后端开发"),

    DATA_WAREHOUSE_DEVELOPMENT_COMPLETED(33, "完成数仓开发"),
    ALGORITHM_DEVELOPMENT_COMPLETED(34, "完成算法开发"),
    BIG_DATA_DEVELOPMENT_COMPLETED(35, "完成大数据开发"),
    MOBILE_DEVELOPMENT_COMPLETED(36, "完成移动端开发"),
    APP_ADAPTATION_DEVELOPMENT(37, "完成App适配开发"),
    //所有端
    ALL_DEVELOPMENT_COMPLETED(38, "完成开发"),
    // 一般不用这个
    DEVELOPMENT_COMPLETED_DEBUG(39, "完成开发并开始联调"),


    // 联调
    BEGIN_DEBUG(40, "开始联调"),

    INTEGRATION_TESTING_COMPLETED_SUBMIT_TEST(50, "完成联调并提测"),

    INTEGRATION_TESTING_COMPLETED(51, "完成联调"),


    //测试
    BEGIN_TESTING(60, "开始测试"),
    BEGIN_APP_TESTING(61, "开始APP测试"),

    TESTING_COMPLETED(70, "完成测试"),
    FINISH_APP_TESTING(71, "完成APP测试"),

    // 前后端上线
    RELEASED_TO_PRODUCTION(80, "发版上线和验收"),
    // 小程序提审
    SUBMIT_AUDIT(81, "应用程序提审"),

    // APP适配相关定义
    APP_ADAPTATION_RELEASE(82, "APP适配上线"),
    APP_VERSION_RELEASE(83, "APP发版");

    private final Integer value;

    private final String description;

    MilestoneType(Integer value, String description) {
        this.value = value;
        this.description = description;
    }


    /**
     * 根据值查找枚举实例。
     *
     * @param value 枚举值
     * @return 枚举实例
     */
    public static MilestoneType fromValue(int value) {
        for (MilestoneType milestoneType : values()) {
            if (milestoneType.getValue() == value) {
                return milestoneType;
            }
        }
        throw new IllegalArgumentException("No matching MilestoneType for value: " + value);
    }


    /**
     * 根据值查找描述
     *
     * @param value 枚举值
     * @return 描述字符串
     */
    public static String getDescriptionByValue(Integer value) {
        for (MilestoneType milestoneType : values()) {
            if (milestoneType.getValue().equals(value)) {
                return milestoneType.getDescription();
            }
        }
        throw new IllegalArgumentException("No matching MilestoneType for value: " + value);
    }

    public static Integer getValueByDescription(String description) {
        for (MilestoneType milestoneType : values()) {
            if (milestoneType.getDescription().equals(description)) {
                return milestoneType.getValue();
            }
        }
        throw new IllegalArgumentException("No matching MilestoneType for description: " + description);
    }

}
